<?php

namespace app\api\model;

use think\Model;

class UserChallenge extends Model
{
    public static function getRecordToday($userId)
    {
        return self::where('uid', '=', $userId)
            ->where('date', '>=', strtotime(date('Y-m-d')))
            ->find();
    }

    public static function getRecordYesterday($userId)
    {
        return self::where('uid', '=', $userId)
            ->where('date', '>=', strtotime(date('Y-m-d')) - 86400)
            ->where('date', '<', strtotime(date('Y-m-d')))
            ->find();
    }
}